import { loginSubject } from '@/service/authService'

const state = {
    
    loginState: -1,     // -1 未登入  0 登入

    userInfo: null,

    userPermission: {}
}

const mutations = {
    setLoginState(state, value) {
        loginSubject.next(value)
        state.loginState = value;
    },

    setUserInfo(state, value) {
        state.userInfo = value;
    },

    setPermission(state,value){
        let temp  = {};
        value.forEach(item=>{
            temp[item.permission] = true
        })
        state.userPermission = temp;
    }
}

const actions = {

}

const getters = {
    
}

export default {
    namespaced: true,
    actions,
    state,
    mutations,
    getters,
}